package com.kube.design.singleton;

/**
 * @author q.zhangr
 * @version 1.0.0
 * @date 2020/7/22
 */
public class Singleton {

    //私有构造函数
    private Singleton() {
    }

    //单例对象
    private volatile static Singleton instance = null;

    //静态的工厂方法
    public static Singleton getInstance() {
        if (instance == null) {
            synchronized (Singleton.class) {
                if (instance == null) {
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }

}
